package com.nba.service.impl;

import java.util.List;

import com.nba.bean.Page;
import com.nba.bean.Player;
import com.nba.bean.inherit.PlayerInherit;
import com.nba.dao.PlayerDao;
import com.nba.dao.impl.PlayerDaoImpl;
import com.nba.service.PlayerService;

public class PlayerServiceImpl implements PlayerService {
	
	private PlayerDao playerdao = new PlayerDaoImpl();
	
	@Override
	public List<Player> getAllplayer() {
		return playerdao.selectPlayerAll();
	}

	@Override
	public Player getplayerById(int playerId) {
		// TODO Auto-generated method stub
		return playerdao.selectPlayerById(playerId);
	}

	@Override
	public int deletePlayer(int playerId) {
		// TODO Auto-generated method stub
		return playerdao.delectPlayerById(playerId);
	}

	@Override
	public int addPlayer(Player player) {
		// TODO Auto-generated method stub
		return playerdao.insertPlayer(player);
	}

	@Override
	public int updatePlayer(Player player) {
		// TODO Auto-generated method stub
		return playerdao.updatePlayer(player);
	}

	@Override
	public Page<PlayerInherit> getPlayer(String keyword, int pageNum, int pageSize) {
		List<PlayerInherit> players = playerdao.selectPlayerAll(keyword, pageNum, pageSize);
		int totalRows = playerdao.selectPlayerTotal(keyword);
		Page<PlayerInherit> page  =  new Page<PlayerInherit>(players, pageNum, pageSize, totalRows);
		return page;
	}

	@Override
	public Player selectPlayerByName(String playerName) {
		return playerdao.selectPlayerByName(playerName);
	}

}
